package com.blb.thread;

public class BaoziDemo {

    public static void main(String[] args) {
        BaoziShop shop = new BaoziShop();
        //生产者生产包子
        Thread thread = new Thread(()->{
            for (int i = 0;i < 200;i++){
                shop.makeBaozi();
            }
        });
        thread.setName("包子师傅老张");
        thread.start();
        //消费者吃包子
        for (int i = 0; i < 10; i++) {
            Thread thread1 = new Thread(() -> {
                for (int j = 0; j < 20; j++) {
                    shop.sellBaozi();
                }
            });
            thread1.setName("消费者" + i);
            thread1.start();
        }

    }
}
